<!-- D:/project/app/ydz-app-uniapp/static/images/knowledge/disease -->
<template>
	<view class="pagebody">
		<view class="topbox">
			<TopSearch></TopSearch>
		</view>
		<view class="banner">
		</view>
		<view class="conbox">
			<view class="title">
				{{detail.name}}
			</view>
			<view class="timebox">
				<span>已帮助: {{detail.hits}}人</span>
				<span>{{detail.updateTime}} </span>
			</view>
			<consulting></consulting>
			<view class="content" v-html="detail.content">
			</view>
			<view class="reference_material">
				参考资料： {{detail.referenceMaterial?detail.referenceMaterial:ydzsetobj.referenceMaterial}}
			</view>
			<view class="disclaimers">
				<span class="disclaimers_font">免责声明：</span>
				{{detail.disclaimers?detail.disclaimers:ydzsetobj.disclaimers}}
			</view>
		</view>
		<AdvCom :type='2'></AdvCom>
		<NewslistCom :head="1" :newsList="newsList" style="border-radius: 32rpx 32rpx 0 0;"></NewslistCom>
		<community></community>
		<typenews :type="1" :disid="userDocument.diseaseId" :list="othernewslist"></typenews>
		<AboutDrug :drugList="drugList"></AboutDrug>
		<AdvCom :type='4'></AdvCom>
		<AboutClinical :clinicalList="clinicalList"></AboutClinical>
		<HotnewsCom></HotnewsCom>
		<FixedFoot :typeid="2"></FixedFoot>
	</view>
</template>

<script>
	import TopSearch from '../../layouts/topsearch.vue';
	import consulting from '../../components/generalcom/consulting.vue'
	import AdvCom from '../../layouts/advcome.vue';
	import NewslistCom from '../../components/generalcom/newslistcom.vue';
	import typenews from '../../components/generalcom/typenews.vue';
	import community from '../../components/generalcom/community.vue'
	import AboutDrug from '../../components/generalcom/aboutdrug.vue';
	import AboutClinical from '../../components/generalcom/aboutclinical.vue';
	import HotnewsCom from '../../components/generalcom/hotnewcom.vue';
	import FixedFoot from '../../layouts/fixedfoot.vue';
	import {
		getotherlist,
		getNewsList,
		getotherById,
		getDrugList,
		getClinicalList,
		updateOtherNewsHis,
		getydzSet
	} from '@/api/api.js'
	import {
		getInfo
	} from '@/api/login'
	export default {
		components: {
			TopSearch,
			NewslistCom,
			consulting,
			AdvCom,
			typenews,
			community,
			AboutDrug,
			AboutClinical,
			HotnewsCom,
			FixedFoot
		},
		onLoad(option) {
			this.getUser()
			this.getdetail(option.id);
			this.updateOtherNewsHis(option.id);
			this.getset();
		},
		data() {
			return {
				userDocument: {},
				drugList: [],
				newsList: [],
				othernewslist: [],
				diseaseList: [],
				detail: {},
				clinicalList: [],
				ydzsetobj: {},

			};
		},
		methods: {
			updateOtherNewsHis(id) {
				updateOtherNewsHis(id).then(res => {})
			},
			getset() {
				getydzSet().then(res => {
					this.ydzsetobj = res.data
				})
			},
			getUser() {
				getInfo().then(res => {
					this.userDocument = res.userDocument
					let dis = {
						"diseaseId": this.userDocument.diseaseId
					}
					this.diseaseList.push(dis);
					this.getDrugList()
					this.getNewsList()
					this.otherlist()
					this.getClinicalList();

				})
			},
			getdetail(id) {
				console.log(id)
				getotherById(id).then(res => {
					this.detail = res.data
				})
			},
			getNewsList() {
				let param = {
					"pageNum": 1,
					"pageSize": 4,
					"orderByColumn": "create_time",
					"isAsc": "desc",
					"state": "1",
					"diseaseId": this.userDocument.diseaseId,
				}
				//相关文章
				getNewsList(param).then(response => {
					this.newsList = response.rows
					this.total = response.total
					this.newsList.forEach(item => {
						let str = item.content
						if (str) {
							let words = str.replace(/<[^<>]+>/g, "").replace(/&nbsp;/gi, "")
							str = words.replace(/\s/g, "")
							item.nostyletext = str
						}
					})

				})
			},
			otherlist() {
				let params = {
					"pageNum": 1,
					"pageSize": 5,
					"type": "01",
					"state": "1",
					"orderByColumn": "create_time",
					"isAsc": "desc",
					"diseaseId": this.userDocument.diseaseId
				}
				getotherlist(params).then(res => {
					this.othernewslist = res.rows
				})
			},
			// 药品列表
			getDrugList() {
				let param = {
					"pageNum": 1,
					"pageSize": 4,
					"state": "1",
					"orderByColumn": "create_time",
					"isAsc": "desc",
					"drugDiseaseList": this.diseaseList.length > 0 ? this.diseaseList : null
				}
				getDrugList(param).then(res => {
					if (res.code == 200) {
						this.drugList = res.rows
					}
				})
			},
			// 临床招募列表
			getClinicalList() {
				let param = {
					"pageNum": 1,
					"pageSize": 6,
					"state": "1",
					"orderByColumn": "create_time",
					"isAsc": "desc",
					"clinicalDiseaseList": this.diseaseList.length > 0 ? this.diseaseList : null
				}
				getClinicalList(param).then(res => {
					if (res.code == 200) {
						this.clinicalList = res.rows
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.pagebody {
		padding-bottom: 136rpx;

		.topbox {
			padding: 20rpx 24rpx;
			background: #fff;
			border-bottom: 1px solid #dedede;
		}

		.banner {
			height: 388rpx;
			background: url(@/static/images/knowledge/disease/znbanner.png) no-repeat;
			background-size: contain;
		}

		.conbox {
			padding: 36rpx 24rpx;
			border-radius: 48rpx;
			margin-top: -90rpx;
			background: #fff;

			.title {
				font-weight: bold;
				font-size: 42rpx;
				color: #303B39;
				line-height: 64rpx;
			}

			.timebox {
				margin: 24rpx 0 32rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 24rpx;
				color: #7E8987;
				line-height: 24rpx;
			}

			.content {
				padding: 40rpx 0;
				color: #293347;
				font-size: 36rpx;
				line-height: 72rpx;
				margin-top: 16rpx;
				margin-bottom: 16rpx;
				text-indent: 36rpx;

				::v-deep h2 {
					color: #00977C;
					font-size: 38rpx;
					font-weight: 800;
					position: relative;
					padding-left: 12rpx;
					margin-bottom: 24rpx;
					line-height: 72rpx;

					&::before {
						content: "";
						position: absolute;
						left: 0;
						top: 18rpx;
						width: 8rpx;
						height: 38rpx;
						background: #00977C;
						border-radius: 8px 8px 8px 8px;
					}
				}

				::v-deep h3 {
					color: #00977C;
					font-size: 38rpx;
					line-height: 72rpx;
					font-weight: 800;
					margin-bottom: 24rpx;
				}

				::v-deep h4 {
					color: #303B39;
					font-size: 38rpx;
					line-height: 72rpx;
					margin-bottom: 24rpx;
					font-weight: 800;
				}

				::v-deep p {
					color: #303B39;
					font-size: 36rpx;
					line-height: 72rpx;
					margin-bottom: 40rpx;
					font-weight: 400;
				}
			}

			.reference_material {
				font-weight: 400;
				font-size: 28rpx;
				color: #303B39;
				line-height: 56rpx;
				margin-top: 32rpx;
				word-break: break-all;
			}

			.disclaimers {
				background: #F0F6F5;
				border-radius: 8rpx;
				padding: 16rpx;
				margin-top: 32rpx;
				font-weight: 400;
				font-size: 28rpx;
				color: #576260;
				line-height: 56rpx;

				.disclaimers_font {
					color: #00D9B2;
				}
			}
		}
	}
</style>